package offerv1;

public class Offer10_1 {

    public int numWays(int n) {
        if (n == 0) {
            return 1;
        }

        if (n == 1) {
            return 1;
        }

        int[] dict = new int[n + 1];
        dict[0] = 1;
        dict[1] = 1;
        for (int i = 2; i < n + 1; i++) {
            dict[i] = (dict[i - 1] + dict[i - 2]) % 1000000007;
        }
        return dict[n];
    }

    public int numWays1(int n) {
        int a = 1, b = 1, sum;
        for (int i = 0; i < n; i++) {
            sum = (a + b) % 1000000007;
            a = b;
            b = sum;
        }
        return a;
    }
}
